const BASE_URL1 = "https://nodes.kimhiz.asia/api";
const BASE_URL = "http://localhost:3333/api";

export function httpGet(url: string, header: any = {}, data = {}) {
  header["Content-Type"] = "application/json";
  return new Promise((resolve, reject) => {
    uni.request({
      url: BASE_URL1 + url,
      method: "GET",
      header: header,
      data: data,
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data);
        } else {
          reject(res);
        }
      },
      fail: (err) => {
        reject(err);
      },
    });
  });
}

export function httpPost(url: string, header: any = {}, data = {}) {
  header["Content-Type"] = "application/json";
  return new Promise((resolve, reject) => {
    uni.request({
      url: BASE_URL1 + url,
      method: "POST",
      header: header,
      data: data,
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data);
        } else {
          reject(res);
        }
      },
      fail: (err) => {
        reject(err);
      },
    });
  });
}
